package cn.com.self.apis.controller;


import cn.com.self.apis.core.vo.ResultModel;
import cn.com.self.apis.member.entity.vo.UMemberInfoVO;
import cn.com.self.apis.member.service.IMemberInfoService;
import cn.com.self.apis.portal.entity.dto.RequirementsDTO2;
import cn.com.self.apis.portal.util.ICustomPage;
import cn.com.selfsoft.smartcity.commons.http.DataItem;
import cn.com.selfsoft.smartcity.commons.util.ParameterUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;

/**
 * @author1 ssh
 * @author2
 * @date 2021-04-28
 */
@Controller
@Api(tags = "技术中心")
public class TechnologyController {

    @Autowired
    private IMemberInfoService memberInfoService;

    @ApiOperation(value = "分页获取技术中心会员列表")
    @PostMapping("/api/v1/memberInfo/page")
    @ApiImplicitParams({
            @ApiImplicitParam (name = "provinces", value = "所在省份字典值集合：5,8,6",paramType = "query",required = false) ,
            @ApiImplicitParam (name = "classificationIds", value = "行业分类id集合：1348887637934870530,1348887637934870535",paramType = "query",required = false),
            @ApiImplicitParam(name = "SCLYdatatypeIds", value = "擅长领域id集合：373,374",paramType = "query",required = false),
            @ApiImplicitParam(name = "JSYYdatatypeIds", value = "技术语言字典id集合：430,431",paramType = "query",required = false) ,
            @ApiImplicitParam(name = "sort", value = "排序(字段工作年限work_Year,技术等级level,浏览量show_Num)(desc降序，asc升序)格式：level desc",paramType = "query",required = false),
            @ApiImplicitParam(name = "nameOrtelephone", value = "关键字查询：昵称模糊查询、手机号完整查询",paramType = "query",required = false),
            @ApiImplicitParam(name = "size", value = "分页大小：默认10",paramType = "query",required = false) ,
            @ApiImplicitParam(name = "page", value = "页码：默认1",paramType = "query",required = false)
    })
    public ResponseEntity getMemberInfoPage(HttpServletRequest request, Pageable page   ) {

        try {
            Map<String, Object> queryParams = ParameterUtil.HumpToUnderline(request.getParameterMap(), "mark", "size", "page","sort","access_token");
            queryParams.put("memberType","1");
            ICustomPage<UMemberInfoVO> result= memberInfoService.queryMemberInfoToTechnology(queryParams,page);
            return ResponseEntity.status(HttpStatus.OK).body(new ResultModel<>(new DataItem(result)));

        }catch (Exception e){
            Map<String, Object> result =new HashMap<>();
            System.out.println(e);
            result.put("code",500);
            result.put("error",e);
            return ResponseEntity.status(HttpStatus.OK).body(result);
        }


    }

    @ApiOperation(value = "根据会员id或会员信息id查询技术人员信")
    @PostMapping("/api/v1/memberInfo/getMemberInfobyMemberId")
    public ResponseEntity getMemberInfobyMemberId(HttpServletRequest request,
             @ApiParam(name = "memberId", value = "会员id" ,required = true) @RequestParam String memberId
             ) {
        Map<String, Object> result = new HashMap<>();
        try {
            Map<String, Object> queryParams = new HashMap<>();
            queryParams.put("memberId",memberId);
            UMemberInfoVO uMemberInfoVO = memberInfoService.queryMemberInfobyMemberId(queryParams);
            result.put("data", uMemberInfoVO);
            result.put("code", 200);
            return ResponseEntity.status(HttpStatus.OK).body(result);
        } catch (Exception e) {
            System.out.println(e);
            result.put("code", 500);
            result.put("error", e);
            return ResponseEntity.status(HttpStatus.OK).body(result);
        }
    }


//    /**分页获取会员列表
//     * @Description //TODO
//     * @return
//     **/
//    @ApiOperation(value = "分页获取会员列表")
//    @RequestMapping(value = "/memberInfo/page", method = RequestMethod.GET)
//    @ResponseBody
//    @ApiImplicitParams({
//            @ApiImplicitParam(paramType="query", name = "page", value = "页码", required = false, dataType = "String"),
//            @ApiImplicitParam(paramType="query", name = "size", value = "一页显示条数", required = false, dataType = "String"),
//            @ApiImplicitParam(paramType="query", name = "classification", value = "行业分类", required = false, dataType = "String"),
//            @ApiImplicitParam(paramType="query", name = "scly", value = "擅长领域", required = false, dataType = "String"),
//            @ApiImplicitParam(paramType="query", name = "jsyy", value = "技术语言", required = false, dataType = "String"),
//           /* @ApiImplicitParam(paramType="query", name = "recommend", value = "推荐", required = false, dataType = "String"),
//            @ApiImplicitParam(paramType="query", name = "showNum", value = "浏览量", required = false, dataType = "String"),*/
//            @ApiImplicitParam(paramType="query", name = "orderType", value = "排序（1推荐，2浏览量）", required = false, dataType = "String"),
//            @ApiImplicitParam(paramType="query", name = "name", value = "昵称", required = false, dataType = "String"),
//            @ApiImplicitParam(paramType="query", name = "province", value = "省份", required = false, dataType = "String")
//    })
//    public ResponseEntity getEscrowInfoPage(HttpServletRequest request, Pageable page){
//        return this.memberInfoService.getMemberInfoPageByPortal(request,page);
//
//    }

}

